'use strict';

const { Service } = require('egg');

class MemberService extends Service {

  /**
   *  create a member model
   * @param {Member} member  member model
   */
  async create(member) {
    let newMember = new this.ctx.model.Member();
    newMember = Object.assign(newMember, member);
    newMember.save();
  }
  /**
   * find  a member by member id
   * @param {String } memberId  member id 
   */
  async findById(memberId) {
    return this.ctx.model.Member.find({
      userId: memberId
    });
  }

  async findAll() {
    return this.ctx.model.Member.find({});
  }
}

module.exports = MemberService;
